#include "qtevirtualkeyboardglobal.h"
#include <QInputMethodQueryEvent>
#include <QCoreApplication>

namespace QTE
{

Q_DECL_HIDDEN QString inputMethodName(Language language)
{
	switch(language)
	{
		case LGG_GeneralEnglish:    return "English";
		case LGG_SimplifiedChinese: return "简体中文";
		default: break;
	}
	return "InvalidInputMethod";
}

Q_DECL_HIDDEN QString inputMethodAbbreviation(Language language)
{
	switch(language)
	{
		case LGG_GeneralEnglish:    return "EN";
		case LGG_SimplifiedChinese: return "中";
		default: break;
	}
	return "??";
}

Q_DECL_HIDDEN bool needInputMethod(QObject *object)
{
	if( object == nullptr )
		return false;

	QInputMethodQueryEvent imEvent(Qt::ImQueryInput | Qt::ImEnabled);
	QCoreApplication::sendEvent(object, &imEvent);
	return imEvent.value(Qt::ImEnabled).toBool();
}

} //namespace JXQ
